package com.frejoys.app.controller;

import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.common.IdDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.vo.app.StoreCategoryListVo;
import com.frejoys.service.StoreCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "店铺商品分类", description = "店铺商品分类")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixApp)
@Authorization(Authority.Private)
public class StoreCategoryController {

    private final StoreCategoryService storeCategoryService;

    @Authorization(Authority.Protected)
    @Operation(summary = "根据店铺id查询店铺下的分类")
    @PostMapping("/category/storeIdCategory")
    public Result<List<StoreCategoryListVo>> storeIdCategory(@RequestBody @Validated IdDto dto){
        return Result.success(storeCategoryService.storeIdCategory(dto.getId()));
    }

}
